$(function(){
	var walletType=sessionStorage.getItem("walletType");
	var logonToken=sessionStorage.getItem("logonToken");
	var playId=sessionStorage.getItem("playId");
	
	
//	获取数据
	var page=1;
	var page1=1;
	var rows=3;
	function persona_list(page,type){
		if(type == 3){
			var json = {
		        "logonToken": logonToken,
		        "walletType": walletType,
		        "playId":playId,
		        "page":page1,
		        "rows":rows
		    }
		}else{
			var json = {
		        "logonToken": logonToken,
		        "walletType": walletType,
		        "playId":playId,
		        "page":page,
		        "rows":rows
		    }
		}
		
	    $.ajax({
	        type: "post",
	        url: url + '/bigWinner/api/profit/myProfit',
	        data: JSON.stringify(json),
	        dataType: 'json',
	        contentType: "application/json",
	        success: function(result) {
	            if(result.success) {
	            	var html ='';
	            	var html1 ='';
	            	var html2 ='';
	            	var data=result.obj;
	            	for(var i in data){
//	                                                 个人收益
	            		html += '<div class="col-xs-12"><div class="earnMain">';
	                    html += '<p>ID<span>'+data[i].playId+'</span></p>';
	                    if(data[i].walletType == "0"){
	                    	html += '<p>币种<span>BTC</span></p>';
	                    }else{
	                    	html += '<p>币种<span>ETH</span></p>';
	                    }
	                    html += '<p>活动<span>'+data[i].activityName+'</span></p>';
	                    html += '<p>轮数<span>第'+data[i].num+'轮</span></p>';
	                    html += '<p>投入<span>'+data[i].investmentAmount+'</span></p>';

	                    html += '<p>收益<span>'+data[i].profit+'</span></p>';
	                    html += '<p>时间<span>'+data[i].addTime+'</span></p>';
	                    if(data[i].profitStatus == "0"){
	                    	html += '<p>状态<span>待返还</span></p></div></div>';
	                    }else{
	                    	html += '<p>状态<span>已发放</span></p></div></div>';
	                    }
	                    
	                    
	                    
	                    
	                    
//	                                                   团队收益
						html2 += '<div class="col-xs-12"><div class="earnMain">';
	                    html2 += '<p>ID<span>'+data[i].playId+'</span></p>';
	                    if(data[i].walletType == "0"){
	                    	html2 += '<p>币种<span>BTC</span></p>';
	                    }else{
	                    	html2 += '<p>币种<span>ETH</span></p>';
	                    }
	                    html2 += '<p>数量<span>'+data[i].teamProfit+'</span></p>';
	                    html2 += '<p>是否为团队分红<span>是</span></p>';
	                    html2 += '<p>时间<span>'+data[i].addTime+'</span></p>';
	                    if(data[i].teamStatus == "0"){
	                    	html2 += '<p>状态<span>待返还</span></p></div></div>';
	                    }else{
	                    	html2 += '<p>状态<span>已发放</span></p></div></div>';
	                    }
	            	}
	            	if(html == ""){
	            		if(type == 1){
		            		$(".load_more").eq(0).html("暂无更多");
		            		$(".load_more").eq(1).html("暂无更多");
		            	}else if(type == 2){
		            		$(".load_more").eq(0).html("暂无更多");
		            	}else if(type == 3){
		            		$(".load_more").eq(1).html("暂无更多");
		            	}
	            	}else{
	            		if(type == 1){
		            		$(".myEar_list").append(html);
		            		$(".myEar_list_1").append(html2);
		            	}else if(type == 2){
		            		$(".myEar_list").append(html);
		            	}else if(type == 3){
		            		$(".myEar_list_1").append(html2);
		            	}
	            	}
	            } else {
	            	isErr(result);
	            }
	        },
	        error: function(XMLHttpRequest, textStatus, errorThrown) {
	            alert("请求失败："+XMLHttpRequest.status);
	        }
	    });
	}
 	
    
    persona_list(page,1);
	
	$(".load_more").on("click",function(){
		if($(this).attr("data") == "3"){
			if($(this).html() != "暂无更多"){
				page1++;
				persona_list(page,3);
			}
		}else{
			if($(this).html() != "暂无更多"){
				page++;
				persona_list(page,2);
			}
		}
		
	})
})
